//
// Created by Lenovo on 2021/12/14.
//

#ifndef SQLIST_SQLIST_H
#define SQLIST_SQLIST_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LIST_INIT_SIZE 100  //线性表存储空间的初始分配量
#define LIST_INCREMENT 10   //线性表存储空间的分配增量

enum Status {OK=0,ERROR=-1,MY_OVERFLOW=-2,EMPTY=-3,TRUE=1,FALSE=0};
typedef enum Status Status;

typedef int ElemType;//确定元素子类型

typedef struct {
    ElemType * elem;    //存储空间基地址
    int length;         //当前长度
    int list_size;      //当前分配的储存容量以sizeof（ElemType）为单位
}SqList;

Status InitList_Sq(SqList* L);   //构造一个空的线性表
Status ListInsert_Sq(SqList* L,int i,ElemType e);    //再线性表的第i个元素处插入
ElemType ListDelete_Sq(SqList* L,int i);   //删除线性表第i个元素
int LocateElem_Sq(const SqList *L,ElemType e,int(*compareSame)(ElemType e,ElemType f)); //获取元素e在线性表中的位置（需要用户自定义元素比较函数）
void MergeList_Sq(const SqList *La,SqList Lb,SqList* Lc,int(*compareDifference)(ElemType e,ElemType f));  //将两个线性表合并
void ClearList_Sq(SqList *L);   //将线性表置空
void DestroyList_Sq(SqList *L);    //销毁线性表
ElemType GetElem_Sq(const SqList *L,int i);  //获取线性表中第i个元素
ElemType PriorElem_Sq(const SqList *L,ElemType cur_e,int(*compareSame)(ElemType e,ElemType f));  //获取元素e的前一个元素
ElemType NextElem_Sq(const SqList *L,ElemType cur_e,int(*compareSame)(ElemType e,ElemType f));   //获取元素e的后一个元素
void ListTraverse_Sq(SqList *L,void(*Visit)(ElemType)); //遍历线性表
Status ListPushBack_Sq(SqList *L,ElemType e);//顺序线性表尾插

#endif //SQLIST_SQLIST_H
